package com.example.friend.controller;

import com.example.api.entity.UserQuestionResultVO;
import com.example.core.controller.BaseController;
import com.example.core.result.Res;
import com.example.friend.entity.DTO.UserSubmitDTO;
import com.example.friend.service.IUserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {
    @Autowired
    private IUserQuestionService userQuestionService;

    //用户代码提交   请求方法  地址  参数  响应数据结构
    @PostMapping("/submit")
    public Res<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO submitDTO) {
        return userQuestionService.submit(submitDTO);
    }


    @PostMapping("/rabbit/submit")
    public Res<Void> rabbitSubmit(@RequestBody UserSubmitDTO submitDTO) {
        return toR(userQuestionService.rabbitSubmit(submitDTO));
    }


    @GetMapping("/exe/result")
    public  Res<UserQuestionResultVO> exeResult(Long examId, Long questionId, String currentTime) {
        return Res.ok(userQuestionService.exeResult(examId, questionId, currentTime));
    }
}
